package com.example.physicalexaminationsystem.controller;

import com.example.physicalexaminationsystem.dto.ResponseDto;
import com.example.physicalexaminationsystem.service.DepartmentService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author shiwenzhuo
 * 
 * @description
 */
@RestController
@RequestMapping("/api/department")
public class DepartmentController {
    @Resource
    private DepartmentService departmentService;

    //添加科室信息
    @RequestMapping("/addDepartment")
    public ResponseDto addDepartment(@RequestBody Map<String, Object> params) {
        departmentService.addDepartment(params);
        return ResponseDto.success();
    }

    //获取科室信息
    @RequestMapping("/getDepartmentList")
    public ResponseDto getDepartmentList() {
        return ResponseDto.success(departmentService.getDepartmentList());
    }

    //删除科室信息
    @RequestMapping("/deleteDepartmentById")
    public ResponseDto deleteDepartmentById(@RequestParam Long id) {
        departmentService.deleteDepartmentById(id);
        return ResponseDto.success();
    }

    //修改科室信息
    @RequestMapping("/updateDepartment")
    public ResponseDto updateDepartment(@RequestBody Map<String, Object> params) {
        departmentService.updateDepartmentById(params);
        return ResponseDto.success();
    }
}
